package com.ruoyi.system.ali;

import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.enums.ChannelEnum;
import com.ruoyi.system.vo.ChannelCodeVo;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ChannelCodeService {


    public List<ChannelCodeVo> listHandle() {
        List<ChannelCodeVo> listAll = listAll();

        List<ChannelCodeVo> listAuto = listAuto();

        listAll.removeAll(listAuto);

        return listAll;
    }


    public List<ChannelCodeVo> listAll() {
        List<ChannelCodeVo> list = new ArrayList<>();
        for (ChannelEnum item : ChannelEnum.values()) {
            ChannelCodeVo channelCodeVo = new ChannelCodeVo();
            channelCodeVo.setLabel(item.getCode());
            channelCodeVo.setType(item.getName());
            list.add(channelCodeVo);
        }
        return list;
    }

    public List<ChannelCodeVo> listAuto() {
        List<ChannelCodeVo> list = new ArrayList<>();
        for (ChannelEnum item : ChannelEnum.values()) {
            ChannelCodeVo channelCodeVo = new ChannelCodeVo();
            if (StrUtil.equals(item.getCode(), ChannelEnum.H5.getCode()) ||
                    StrUtil.equals(item.getCode(), ChannelEnum.FACE.getCode())
            ) {
                channelCodeVo.setLabel(item.getCode());
                channelCodeVo.setType(item.getName());
                list.add(channelCodeVo);
            }


        }
        return list;
    }

}
